package service

import (
	"k8s-platform/config"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/clientcmd"
)

//用于初始化k8s clientset

var K8s k8s

type k8s struct {
	ClientSet *kubernetes.Clientset
}

//初始化
func (k *k8s) Init() {
	config.GetConfig()
	cfg , err := clientcmd.BuildConfigFromFlags("",config.Kubeconf)
	if err != nil {
		panic("获取k8s的config配置文件失败" + err.Error())
	}
	clientset , err := kubernetes.NewForConfig(cfg)
	if err != nil {
		panic("创建k8s client 失败" + err.Error())
	}

	K8s.ClientSet = clientset

}


































